|
1
|
|
|
// i don't want readers to think it's a white |
|
2
|
|
|
// space, it's just an empty string |
|
3
|
|
|
const EMPTY_CHARACTER = ''; |
|
4
|
|
|
|
|
5
|
|
|
const GEEZ_NUMBERS = { |
|
6
|
|
|
0: '', |
|
7
|
|
|
1: '፩', |
|
8
|
|
|
2: '፪', |
|
9
|
|
|
3: '፫', |
|
10
|
|
|
4: '፬', |
|
11
|
|
|
5: '፭', |
|
12
|
|
|
6: '፮', |
|
13
|
|
|
7: '፯', |
|
14
|
|
|
8: '፰', |
|
15
|
|
|
9: '፱', |
|
16
|
|
|
10: '፲', |
|
17
|
|
|
20: '፳', |
|
18
|
|
|
30: '፴', |
|
19
|
|
|
40: '፵', |
|
20
|
|
|
50: '፶', |
|
21
|
|
|
60: '፷', |
|
22
|
|
|
70: '፸', |
|
23
|
|
|
80: '፹', |
|
24
|
|
|
90: '፺', |
|
25
|
|
|
100: '፻', |
|
26
|
|
|
10000: '፼', |
|
27
|
|
|
}; |
|
28
|
|
|
|
|
29
|
|
|
/** |
|
30
|
|
|
* Converter class provide the base functionality |
|
31
|
|
|
* for the Ascii and Geez converters. |
|
32
|
|
|
* |
|
33
|
|
|
* @author Sam As End <4sam21{at}gmail.com> |
|
34
|
|
|
*/ |
|
35
|
|
|
module.exports = class Converter { |
|
36
|
|
|
/** |
|
37
|
|
|
* Check if a number is strictly ZERO. |
|
38
|
|
|
* |
|
39
|
|
|
* @return boolean if true it's zero |
|
40
|
|
|
* @param $number |
|
41
|
|
|
*/ |
|
42
|
|
|
isZero($number) { |
|
43
|
|
|
return $number === 0; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* Checks if the number is ፻. |
|
48
|
|
|
* |
|
49
|
|
|
* @return bool |
|
50
|
|
|
* @param $geez_number |
|
51
|
|
|
*/ |
|
52
|
|
|
isGeezNumberHundred($geez_number) { |
|
53
|
|
|
return this.isGeezNumber($geez_number, 100); |
|
54
|
|
|
} |
|
55
|
|
|
|
|
56
|
|
|
/** |
|
57
|
|
|
* Checks if the geez number character is equal to ascii number. |
|
58
|
|
|
* |
|
59
|
|
|
* @return boolean |
|
60
|
|
|
* @param $geez_number |
|
61
|
|
|
* @param $number |
|
62
|
|
|
*/ |
|
63
|
|
|
isGeezNumber($geez_number, $number) { |
|
64
|
|
|
return $geez_number === Converter.GEEZ_NUMBERS[$number]; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
/** |
|
68
|
|
|
* Checks if the number is ፩. |
|
69
|
|
|
* |
|
70
|
|
|
* @param $geez_number |
|
71
|
|
|
* @return bool |
|
72
|
|
|
*/ |
|
73
|
|
|
isGeezNumberOne($geez_number) { |
|
74
|
|
|
return this.isGeezNumber($geez_number, 1); |
|
75
|
|
|
} |
|
76
|
|
|
|
|
77
|
|
|
/** |
|
78
|
|
|
* Checks if the number is ፼ |
|
79
|
|
|
* |
|
80
|
|
|
* @param $geez_number |
|
81
|
|
|
* @return bool |
|
82
|
|
|
*/ |
|
83
|
|
|
isGeezNumberTenThousand($geez_number) { |
|
84
|
|
|
return this.isGeezNumber($geez_number, 10000); |
|
85
|
|
|
} |
|
86
|
|
|
}; |
|
87
|
|
|
|
|
88
|
|
|
Object.defineProperty(module.exports, 'EMPTY_CHARACTER', { |
|
89
|
|
|
value: EMPTY_CHARACTER, |
|
90
|
|
|
writable: false, |
|
91
|
|
|
enumerable: true, |
|
92
|
|
|
configurable: false, |
|
93
|
|
|
}); |
|
94
|
|
|
|
|
95
|
|
|
Object.defineProperty(module.exports, 'GEEZ_NUMBERS', { |
|
96
|
|
|
value: GEEZ_NUMBERS, |
|
97
|
|
|
writable: false, |
|
98
|
|
|
enumerable: true, |
|
99
|
|
|
configurable: false, |
|
100
|
|
|
}); |
|
101
|
|
|
|
|
102
|
|
|
// module.exports.EMPTY_CHARACTER = EMPTY_CHARACTER; |
|
103
|
|
|
// module.exports.GEEZ_NUMBERS = GEEZ_NUMBERS; |
|
104
|
|
|
|